package api

import (
	"github.com/gin-gonic/gin"
	"github.com/share309/gojwt"
	"user_5.24/api/handler"
	"user_5.24/consts"
)

func LoadRouters(r *gin.Engine) {
	r.GET("/ping", handler.Ping)
	api := r.Group("/api")
	{
		user := api.Group("/user")
		{
			user.POST("/register", handler.Register)
			user.POST("/login", handler.Login)
			user.Use(gojwt.JWTAuth(consts.Jwt_KFY))
			user.POST("/refreshJwt", handler.RefreshJwt)
		}
		goods := api.Group("/goods")
		{
			goods.Use(gojwt.JWTAuth(consts.Jwt_KFY))
			goods.POST("/add", handler.GoodsAdd)
			goods.POST("/update", handler.Update)
			goods.GET("/list", handler.List)
			goods.GET("/page", handler.Page)

		}
		collect := api.Group("/collect")
		{
			collect.Use(gojwt.JWTAuth(consts.Jwt_KFY))
			collect.POST("/add", handler.CollectAdd)
			collect.POST("/update", handler.CollectUpdate)
			collect.GET("/list", handler.CollectList)

		}
		
	}
}
